<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{sc "WebTitle" ""}} | 登陆</title>
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="/static/css/animate.css" rel="stylesheet">
    <link href="/static/css/style.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="middle-box text-center loginscreen animated fadeInDown">
    <div>
        <h3>欢迎回来！</h3>
        <p>Login in. To see it in action.</p>
        <form class="m-t" role="form" id="login">
            <div class="form-group">
                <input type="text" class="form-control" placeholder="用户名" required="" name="username">
            </div>
            <div class="form-group">
                <input type="password" class="form-control" placeholder="密码" required="" name="password">
            </div>
            <button type="button" id="submit" class="btn btn-primary block full-width m-b">登陆</button>

        </form>
        <p class="m-t">
            <small>© 2018 {{sc "CopyRight" ""}}. All Rights Reserved</small>
        </p>
    </div>
</div>

<!-- Mainly scripts -->
<script src="/static/js/jquery-3.1.1.min.js"></script>
<script src="/static/js/popper.min.js"></script>
<script src="/static/js/bootstrap.js"></script>
<!-- layer -->
<script src="/static/layer/layer.js"></script>
<script>
    function wait(timeout) {
        if (timeout === 0) {
            window.location.href = "/admin";
        } else {
            setTimeout("wait(0)", 1000);
        }
    }

    $("#submit").click(function () {
        $(document).ready(function () {
            const postData = $("form").serialize();
            $.post("/login", postData, function (res) {
                if (res.error === 0) {
                    layer.msg("登陆成功", {time: 2000});
                    wait(1);
                } else {
                    layer.msg("登陆失败！请检查输入信息是否正确", {time: 2000});
                }
            }, "json");
            return false;
        });
    });
</script>

</body>
</html>
